from django.db import models

from libs.db import BaseModel


class Menu(BaseModel):
    name = models.CharField('名称', max_length=100, unique=True)
    title = models.CharField('标题', max_length=100)
    icon = models.CharField('图标', max_length=100, null=True, blank=True, default='')
    orderNo = models.IntegerField('排序', default=1)
    path = models.CharField('path', max_length=100, null=True, blank=True, default='')
    component = models.CharField('组件', max_length=100, null=True, blank=True, default='LAYOUT')
    hideMenu = models.BooleanField('是否隐藏', default=False)
    enable = models.BooleanField('启用', default=True)
    meta = models.JSONField('meta数据', default=dict)
    permissions = models.JSONField('权限列表', default=list)
    parent = models.ForeignKey(
        to='self',
        related_name='children',
        on_delete=models.SET_NULL,
        blank=True,
        null=True
    )
